'''
Steps:
- Load in supernodes for a given day
- Create a mapping of subnodes to supernodes
- mapping[subnode] = supernode
- Load in relations for a given day
- Load in raw text file
- For each relation:
    - create edge between mapped supernodes with:
        relation
        post text
        sentence text
- Export graph
'''

import pandas as pd
import networkx as nx
import sys


USE_CMDLINE_BASE_DIR = True
# Delimiter for the original csv input file
DELIM = "\n"
OUTPUT_PREFIX = "parler"

def read_df_rel(based_dir, file_input_name):
    file_input = based_dir + file_input_name
    ff = open(file_input)
    delim = ","
    df = pd.read_csv(file_input, delimiter=delim, header=0)
    return df

if __name__ == "main":
    USE_CMDLINE_BASE_DIR = True
    if USE_CMDLINE_BASE_DIR:
        # 2. Main text file of data (i.e. posts)
        main_txt_file_path = str(sys.argv[1])
        # 3. Supernodes list
        super_node_path = str(sys.argv[2])
        # 4. relations extracted csv file
        relations_path = str(sys.argv[3])
    else:
        raise NotImplementedError # TODO: Implement hard coded file if necessary
    df_text = pd.read_csv(main_txt_file_path, delimiter=DELIM, header=0, error_bad_lines=False)
    df_rel = read_df_rel("", relations_path)
    df_supernodes = pd.read_csv(super_node_path)
    print(df_supernodes.head())

